const sequelize = require("../conn");
const { DataTypes } = require("sequelize");
module.exports = {
    comment: '员工表',
    order: [['id', 'desc']],
    model: sequelize.define('staff', {
        id: {
            type: DataTypes.MEDIUMINT.UNSIGNED,
            allowNull: false,
            primaryKey: true,
            autoIncrement: true
        },
        name: {
            type: DataTypes.STRING,
            comment: "姓名"
        },
        sex: {
            type: DataTypes.STRING,
            defaultValue: 2,
            comment: "性别：0 女；1：男；2 未知；"
        },
        age: {
            type: DataTypes.TINYINT,
            comment: "年龄"
        },
        addr: {
            type: DataTypes.STRING,
            comment: "地址"
        },
        idcard: {
            type: DataTypes.CHAR(18),
            comment: "身份证号"
        },
        birthday: {
            type: DataTypes.DATEONLY,
            comment: "出生日期"
        },
        mobile: {
            type: DataTypes.CHAR(18),
            comment: "手机号"
        },
        position: {
            type: DataTypes.TINYINT,
            comment: "职务"
        },
        nickname: {
            type: DataTypes.STRING,
            comment: "昵称"
        },
        openid: {
            type: DataTypes.STRING,
            field: "open_id"
        },
        unionid: {
            type: DataTypes.STRING
        },
        remark: {
            type: DataTypes.TEXT,
            comment: "备注信息"
        }
    }, {
        sequelize,
        tableName: "staff", // 指定表名称，如果不声明表单称，也不强制表名称为模型名称，则系统会自动将模型名称改为复数作为表名称
        // freezeTableName: true,  // 强制使用模型名称作为表名
        timestamps: true,   // 自动在表中添加createdAt、updatedAt字段,
        indexes: [
            { fields: ['name', 'idcard', 'mobile']}
        ]
    })
}